package com.twq.collection.list.firstorder

/**
 * Created by tangweiqun on 2017/12/10.
 */
object Third {
  def main(args: Array[String]): Unit = {
    //1、 Displaying lists: toString and mkString
    val abcde = List('a', 'b', 'c', 'd', 'e')
    abcde.toString

    abcde.mkString

    abcde mkString ""

    abcde mkString("[", ",", "]")

    abcde mkString("List(", ", ", ")")

    //mkString的一个变体方法addString
    //将拼接好的字符串放到StringBuilder中
    val buf = new StringBuilder
    abcde addString(buf, "(", ";", ")")


    //2、Converting lists: iterator, toArray, copyToArray
    val arr = abcde.toArray
    arr.toList

    val arr2 = new Array[Int](10)
    List(1, 2, 3) copyToArray(arr2, 3)
    arr2

    val it = abcde.iterator
    it.next
  }
}
